package com.example.config;

import com.example.interceptors.JwtInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private JwtInterceptor jwtInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor)
                .addPathPatterns("/**")// 拦截所有请求
                .excludePathPatterns("/login")// 放行登录接口
                .excludePathPatterns("/register")// 放行注册接口
                .excludePathPatterns("/files/upload")// 放行文件上传接口
                .excludePathPatterns("/files/download/**")// 放行文件下载接口
        ;
    }
}
